<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/decorators/taglibs.jsp"%>
<div class="w1a">
<div class="w2">系統管理 » 系統日誌管理</div>
<form:form modelAttribute="searchForm" id="searchForm" class="form">
	帳號：<form:input size="10" id="userName" path="userName" />
	IP：<form:input size="10" id="ipAddress" path="ipAddress" />
	SESSION：<form:input size="10" id="session" path="session" />
	作業：
	<form:select path="action" id="action" >
		<form:option value="" label=""/>
		<c:forEach items="${logAction}" var="entity">
	  		<option value="${entity}">${entity.name}</option>
	  	</c:forEach>
	</form:select>
	<a href="#do" class="easyui-linkbutton" onclick="doSearch()">查詢</a>
	<!-- <a href="#do" class="easyui-linkbutton" onclick="doExp()">匯出</a> -->
	<a href="#do" class="easyui-linkbutton" onclick="fmClean()">清空</a>
</form:form><br/>
<table id="tt" class="easyui-datagrid" style="height:360px" url="${appPath}/ftcLog/list.json"   
	sortName="startDateTime" sortOrder="desc" singleSelect="true" striped="true" title="日誌資料" sortable="true" rownumbers="true" pagination="true">  
	<thead>    
    	<tr>   
            <th field="userName" width="60" sortable="true">userName</th>  
            <th field="action" width="80" sortable="true">action</th>
            <th field="objectName" width="140" sortable="true">objectName</th>  
            <th field="objectID" width="100" sortable="true">objectID</th>
            <th field="startDateTime" width="120" sortable="true" formatter="fmDate">startDateTime</th>
            <th field="endDateTime" width="120" sortable="true" formatter="fmDate">endDateTime</th>
            <th field="url" width="160" sortable="true">url</th>
            <th field="ipAddress" width="90" sortable="true">ipAddress</th>
            <th field="session" width="90" sortable="true">session</th> 
		</tr>   
	</thead>   
</table> 
</div>
<script>
function fmDate(val, row){
	var d = new Date(val);
	return d.toLocaleDateString()+" "+d.toLocaleTimeString();
	}	
function doSearch(){ var object = {};
	$.each($('#searchForm').serializeArray(), function(i, v) { object[v.name] = v.value; });
	$('#tt').datagrid('load', object ); 
} 
function doExp(){ 
	var f = document.createElement("form");   
	$(f).attr("method","post");
	$(f).attr("action","${appPath}/ftcLog/exp.htm");
	$.each($('#searchForm').serializeArray(), 
	function(i, v) {$('<input>').attr({type:'text',name:v.name,value:v.value}).appendTo($(f));});
	$(f).submit();
} 
function fmClean(){$("#searchForm").form('reset');}
</script>